/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package business;

import dal.CarDAL;
import java.sql.Date;
import java.util.List;
import model.Car;
import model.CarBooking;
import model.CarInCart;

/**
 *
 * @author khanhanh
 */
public class CarBusiness {

    private CarDAL cDAL = new CarDAL();

    public Car getCarByID(int carID) {
        return cDAL.getCarByID(carID);
    }

    public boolean createCarBooking(int customerID, List<CarInCart> cartCar) {
        try {
            for (CarInCart cIc : cartCar) {
                cDAL.createCarBooking(cIc.getCarID(), customerID, cIc.isDriver(), new Date(cIc.getPickUp().getTime()), new Date(cIc.getDropOff().getTime()), cIc.getQuantity(), cIc.getTotalPerCar());
            }
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    public CarBooking getCarBookingByID(int carBookingID){
        return cDAL.getCarBookingByID(carBookingID);
    }
}
